conf = require("../config")
if not conf.hlslens.enabled then return {} end

return {
  'kevinhwang91/nvim-hlslens',
  -- event = { 'BufReadPost', 'BufNewFile' },
  event = { 'CmdlineEnter' },
  keys = {
    {"n", mode="n"},
    {"N", mode="n"},
    {"*", mode="n"},
    {"#", mode="n"},
    {"g*", mode="n"},
    {"g#", mode="n"},
  },
  config = function ()
    require("hlslens").setup({
      nearest_only = {
        default = false,
      }
    })

    local kopts = {noremap = true, silent = true}

    vim.api.nvim_set_keymap('n', 'n',
      [[<Cmd>execute('normal! ' . v:count1 . 'n')<CR><Cmd>lua require('hlslens').start()<CR>]],
      kopts)
    vim.api.nvim_set_keymap('n', 'N',
      [[<Cmd>execute('normal! ' . v:count1 . 'N')<CR><Cmd>lua require('hlslens').start()<CR>]],
      kopts)
    vim.api.nvim_set_keymap('n', '*', [[*<Cmd>lua require('hlslens').start()<CR>]], kopts)
    vim.api.nvim_set_keymap('n', '#', [[#<Cmd>lua require('hlslens').start()<CR>]], kopts)
    vim.api.nvim_set_keymap('n', 'g*', [[g*<Cmd>lua require('hlslens').start()<CR>]], kopts)
    vim.api.nvim_set_keymap('n', 'g#', [[g#<Cmd>lua require('hlslens').start()<CR>]], kopts)
  end
}

